package com.zx.service;

import com.zx.dao.UserDao;
import com.zx.domain.User;

import java.sql.SQLException;
import java.util.List;

public class UserService {

    public static boolean signIn(String username, String password) {

        List<User> users = UserDao.getUsers();
        if(users!=null){
            for(User u : users){
                if(username.equals(u.getName()) && password.equals(u.getPassword())){
                    return true;
                }
            }
        }
        return false;
    }

    public static boolean addUser(User user) {

        try {
            return UserDao.addUser(user);
        } catch (SQLException e) {
            e.printStackTrace();
            return false;
        }
    }
}
